home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************
- *** SpriteSecretCodes.c
- *** By: Stefan C. Sinclair
- *** Copyright © 1996 All Rights Reserved Worldwide.
- *** Some controlling routines to handle input of the secret codes. Kool, man!
- *******************************************************/
-
- #include "SpriteSecretCodes.h"
-
- char gSecretGameKeys[5] = "????";
-
- extern Boolean gIsRunning, gQT, gSoundOff, gSoundMax, gSoundMegaMax, gSpeech;
- extern Boolean gSecretCode[kNumSecretCodes];
- extern CWindowPtr gWindowP;
-
- char gSecretCodeKeys[kNumSecretCodes][5] =
- {kPongCodeKey, kDoubleDamageCodeKey, kNoRegenerationCodeKey,
- kNoProjectileCodeKey, kNoFatalityCodeKey, kDoubleTimeCodeKey,
- kHighJumpCodeKey, kSuperJACodeKey, kFastProjectileCodeKey,
- kSlowProjectileCodeKey, kSF2KCodeKey, kBGAnimationCodeKey,
- kFGAnimationCodeKey, kNoBGMusicCodeKey};
-
- void MainLoopCodeCheck(char key)
- {
- OSErr myErr;
- short i;
-
- gSecretGameKeys[0] = gSecretGameKeys[1];
- gSecretGameKeys[1] = gSecretGameKeys[2];
- gSecretGameKeys[2] = gSecretGameKeys[3];
- gSecretGameKeys[3] = key;
- c2pstr(gSecretGameKeys);
- for(i=0; i<kNumSecretCodes; i++)
- {
- c2pstr(gSecretCodeKeys[i]);
- // if it's already set, don't bother checking it again
- if(!gSecretCode[i])
- {
- gSecretCode[i] = EqualString((StringPtr)gSecretGameKeys, \
- (StringPtr)gSecretCodeKeys[i],FALSE,FALSE);
- if(gSecretCode[i])
- { // a correct code has been entered!
- Handle codeSoundH;
-
- codeSoundH = Get1Resource('snd ', kSecretCodeSndID);
- if(codeSoundH == NULL)
- CantFindResource();
- HLock(codeSoundH);
- myErr = SndPlay( nil, (SndListHandle)codeSoundH, FALSE);
- HUnlock(codeSoundH);
- ReleaseResource(codeSoundH);
- // reset the key storage to jibberish - notice I start at 1 because the keys are
- // in Pascal style at this point! Tricky!
- gSecretGameKeys[1] = '?';
- gSecretGameKeys[2] = '?';
- gSecretGameKeys[3] = '?';
- gSecretGameKeys[4] = '?';
- }
- }
- p2cstr((StringPtr)gSecretCodeKeys[i]);
- }
- p2cstr((StringPtr)gSecretGameKeys);
-
- // check for codes that demand immediate attention!
- if(gSecretCode[kPongCode])
- {
- Str255 oldWTitle = "\p";
- if(gSpeech && !gSoundOff)
- {
- myErr = SpeakString("\pYou have found the hidden pong game!");
- while(SpeechBusy())
- ;
- myErr = SpeakString("\pHappy Easter!");
- while(SpeechBusy())
- ;
- }
- GetWTitle((WindowPtr)gWindowP, oldWTitle);
- HiddenPongGame((WindowPtr)gWindowP);
- SetWTitle((WindowPtr)gWindowP, oldWTitle);
- // reset the code to "FALSE"
- gSecretCode[kPongCode] = FALSE;
- }
- }